<?php
require_once 'Zend/Application/Resource/ResourceAbstract.php';
require_once 'Core/Service/ShortUrl/BitLy.php';

/**
 * Resource for initializing a file store.
 */
class Core_Application_Resource_Filedb
	extends Zend_Application_Resource_ResourceAbstract
{
	/**
	 * Private cache of configured File DB Instances
	 */
	private $_cache;
	
	/**
	 * Defined by Zend_Application_Resource_Resource
	 *
	 * @return Object
	 */
	public function init()
	{
		return $this;
	}
	
	/**
	 * Retrieve an instance of the document database.
	 * 
	 * @param string $name
	 */
	public function getInstance($name)
	{
		if ( empty($this->_cache[$name]) && isset ($this->_options[$name] ))
		{
			$this->_cache[$name] = Core_DocDb_File::factory($this->_options[$name]);
		}
		
		return $this->_cache[$name];
	}
}
